/* Copyright (c) 2011 Team A CS2340. All rights reserved.*/

package edu.gatech.teama.doctorsoffice.net;

import edu.gatech.teama.doctorsoffice.model.User;
import edu.gatech.teama.doctorsoffice.server.DataModel;

/**
 * Change password message
 * @author Team A
 * @version $Revision: 1.0 $
 *
 */
public class ChangePasswordMessage extends Message {

	/**
	 * User whose password will be changed
	 */
	private final User user;

	/**
	 * New password for the user
	 */
	private final String newPassword;
	
	/**
	 * Change password
	 * @param u user who's password is to be changed
	 * @param newPassword new password
	 */
	public ChangePasswordMessage(User u, String newPassword) {
		super(new Object[] {u, newPassword});
		this.user = u;
		this.newPassword = newPassword;
	}
	
	@Override // $codepro.audit.disable methodJavadoc
	public Message handle(DataModel model) {
		// TODO Auto-generated method stub
		model.changePassword(this.user, this.newPassword);
		return new SuccessMessage(true);
	}

	@Override public String toString() { // $codepro.audit.disable methodJavadoc
		return this.getPayload().toString();
	}
	
}
